<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="js/lib/angular.min.js"></script>
    <link rel="stylesheet" href="css/lib/bootstrap.min.css" />
    <link rel="stylesheet" href="js/themes/default/easyui.css" />
    <script src="js/lib/jquery-1.11.0.js"></script>
    <script src="js/lib/bootstrap.min.js"></script>
    <script src="js/base.js" type="text/javascript" charset="utf-8"></script>
</head>
<style>
    body{
        font-size:12px;
    }
    table,
    th,
    td {
        border: 1px solid grey;
        border-collapse: collapse;
        padding: 5px;
        vertical-align: middle !important;
    }

    table td:nth-child(odd) {
        background-color: #f1f1f1;/*#e2e9ea*/

    }
    table td:nth-child(even) {

    }
    table tr:nth-child(even) {
        background-color:#ffffff;
    }
    input{
        width:280px;
    }
    span{
        width:20px;color:red;display:inline-block;text-align:center;
    }
    #sho{
        width:300px;
        height:50px;
        background:#d9534f;
        opacity:0.8;
        border-radius:8px;
        color:#fff;
        text-align: center;
        font-size:30px;
        position: absolute;
        top:0px;
        left:550px;
        display:none;
    }
</style>
<body ng-app="myApp" ng-controller="customersCtrl">
<div class="">
    <div id="sho"></div>
    <!--第一个查询-->
    <div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
        <table class="table table-hover">
            <tbody>
            <tr>
                <th colspan="8">代理商通道费率修改：</th>
            </tr>
            <tr>
                <td>代理商编号:</td>
                <td colspan="6">
                    <input id="f1" type="text" class="form-control" style="width:280px;"/>
                </td>
            </tr>
            <tr>
                <td>通道编号:</td>
                <td colspan="6">
                    <select name="" id="f2" type="text" class="form-control" style="width:280px;">
                        <option value="">请选择通道</option>
                        <option value="1">快捷支付    T+0</option>
                        <option value="2">快捷支付    T+1</option>
                        <option value="3">微信支付    T+0</option>
                        <option value="4">微信支付   T+1</option>
                        <option value="5">支付宝支付 T+0</option>
                        <option value="6">支付宝支付 T+1</option>
                        <option value="7">QQ支付    T+0</option>
                        <option value="8">QQ支付    T+1</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>费率：</td>
                <td colspan="6">
                    <input id="f3" type="text" class="form-control" placeholder="0.00" maxlength="6"  minlength="4" style="width:280px;display:inline-block;color:red" />&nbsp;
                </td>
            </tr>
            <tr>
                <td>单笔提现手续费：</td>
                <td colspan="6">
                    <div id="f4" type="text" class="form-control" placeholder="0.00" style="width:280px;display:inline-block;color:red" ></div>
                </td>
            </tr>
            <tr>
                <td colspan="8">
                    <button id="query1" class="btn btn-danger" style="margin:0 auto;display:block;">点击修改</button>
                </td>
            </tr>
            <tr>
                <td class="text-center">用户ID</td>
                <td class="text-center">品牌编号</td>
                <td class="text-center">渠道编号</td>
                <td class="text-center">额外费用</td>
                <td class="text-center">提现金额</td>
                <td class="text-center">结算费率</td>
                <td class="text-center">结束时间</td>
            </tr>
            <tr id="show" style="display:none">
                <td class="text-center" id="show1"></td>
                <td class="text-center" id="show2"></td>
                <td class="text-center" id="show3"></td>
                <td class="text-center" id="show4"></td>
                <td class="text-center" id="show5"></td>
                <td class="text-center" id="show6"></td>
                <td class="text-center" id="show7"></td>
            </tr>
            <tr>
                <td colspan="8" id="show01" class="text-center" style="display:none;">

                </td>
            </tr>
            </tbody>
        </table>
    </div>


    <!--第三个查询请求-->
    <div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
        <table class="table table-hover">
            <tr>
                <th style="font-size:30px;" colspan="10">设置用户各通道刷卡费率</th>
            </tr>
            <tr>
                <td style="width:45px;" class="text-center">序号</td>
                <td class="text-center">通道编号</td>
                <td class="text-center">通道名称</td>
                <td class="text-center">T0+T1</td>
                <td class="text-center">单笔最小金额</td>
                <td class="text-center">单笔最大金额</td>
                <td class="text-center">当天最大金额</td>
                <td class="text-center">刷卡费率</td>
                <td class="text-center">修改</td>
                <td class="text-center">结束时间</td>
            </tr>
            <tr ng-repeat="item in items2">
                <td class="text-center">{{$index+1}}</td>
                <td class="text-center">{{item.id}}</td>
                <td class="text-center">{{item.name}}</td>
                <td class="text-center">{{item.channelParams}}</td>
                <td class="text-center">￥{{item.singleMinLimit}}</td>
                <td class="text-center">￥{{item.singleMaxLimit}}</td>
                <td class="text-center">￥{{item.everyDayMaxLimit}}</td>
                <td  class="text-center" contenteditable="true">
                    <input ng-keyup="fd(item)" type="text" class="form-control" ng-model="item.rate" style="width:80px;margin:0 auto;">
                </td>
                <td class="text-center"><button class="btn btn-default" ng-click="add(item)">修改费率</button></td>
                <td class="text-center">{{item.createTime}}</td>
            </tr>
            <tr>
                <td colspan="10" id="show02" class="text-center" style="display:none;">
                </td>
            </tr>
        </table>
    </div>
</div>
</body>
<script>
    $(function(){
        var userid = sessionStorage.getItem(key=13);
        $('#f1').val(userid);
        $('#f2').change(function(){
            var f1 = $("#f1").val();
            var f2 = $('#f2').val();
            console.log($("#f1").val())
            console.log($("#f2").val())
            $.ajax({
                url:window.baseUrl+"user/channel/rate/query/userid",
                type:"POST",
                dataType:"json",
                data:{
                    user_id:f1,
                    channel_id:f2,
                },
                success:function(data){
                    console.log("开始远程调用...")
                    console.log(data.result)
                    $('#f3').val(data.result.rate)
                    $('#f4').html(data.result.withdrawFee+"元")
                },
                error:function(){
                    console.log("调用失败！");
                    $('#show').hide();
                    $('#show01').show().html("暂无数据");
                }
            })
        });
        /*修改用户的通道费率:*/
        $('#f3').on('keyup',function(){
            var v = parseInt($('#f3').val()*10000);
            console.log(v);
            if(v>52){
                $('#f3').val(0.0052)
            }
        });
        $('#f3').on('blur',function(){
            var v= $('#f3').val();
            if(v<0.0035){
                alert('您的费率设置有误！请认真核对')
                $('#f3').val(0.0035)
            }
        });

        $("#query1").click(function(){
            var f1 = $('#f1').val();
            var f2 = $('#f2').val();
            var f3 = $('#f3').val();
            console.log(f1);
            console.log(f2);
            console.log(f3);
            $.ajax({
                url:window.baseUrl+"user/channel/rate/update/userid",
                type:"POST",
                dataType:"json",
                data:{
                    user_id:f1,
                    channel_id:f2,
                    rate:f3
                },
                success:function(data){
                    console.log("开始远程调用...");
                    console.log(data.result);
                    var msg = data.result;
                    if(data.result == null){
                        $('#show').hide();
                        $("#show01").show().html("暂无数据...")
                    }else{
                        alert('成功设置费率为'+msg.rate);
                        window.location.href = "zy03.html";
                        $('#show01').hide();
                        $('#show').show();
                        $('#show1').html(msg.userId);
                        $('#show2').html(msg.brandId);
                        $('#show3').html(msg.channelId);
                        if(msg.extraFee==null){
                            $('#show4').html("-")
                        }else{
                            $('#show4').html(msg.extraFee)
                        };
                        $('#show5').html("￥"+msg.withdrawFee);
                        $('#show6').html(msg.rate+"%");
                        $('#show7').html(msg.createTime);
                    }
                },
                error:function(){
                    console.log("调用失败！");
                    $('#show').hide();
                    $('#show01').show().html("暂无数据");
                }
            })
        })
    })
</script>
<script>
    var app = angular.module('myApp', []);
    /*自定义过滤器   1*/
    app.filter('modify0',function(){
        return function(input,param){
            if(param == "WEIXIN_QRCODE"){
                return param = "微信支付"
            }
            if(param == "ALIPAY_QRCODE"){
                return param = "支付宝支付"
            }
            if(param == "YILIAN"){
                return param = "易联支付"
            }
            if(param == "ZHONGMAO_PAY"){
                return param = "中贸支付"
            }
            if(param == "JIEFUBAO"){
                return param = "京东钱包"
            }
            if(param == "SWIFT_QQ_QRCODE"){
                return param = "qq扫码"
            }
            if(param == "SWIFT_ALIPAY_QRCODE"){
                return param = "支付宝扫码"
            }
            if(param == "SWIFT_WEIXIN_QRCODE"){
                return param = "微信扫码支付"
            }
        }
    });

    app.controller('customersCtrl', function($scope, $http ){
        var userid = sessionStorage.getItem(key=13);
        $('#f1').val(userid);
        /*查询各通道三级分销*/
        $http({
            method: 'POST',
            params: {thirdLevelId:42},
            url: window.baseUrl+'user/thirdlevel/rate/query/thirdlevelid'
        }).then(function successCallback(data){
            console.log("请求数据成功...");
            console.log(data.data.result);
            $scope.items2 = data.data.result
        }, function errorCallback(data) {
            console.log("请求数据失败...");
            console.log(data)
        });
        $scope.fd = function(item){
            console.log(item.rate)
            var rate = item.rate;
            var tag = item.channelTag;
            /*通道 一 判断*/
            if(tag == "YILIAN"){
                if(rate>0.0052){
                    alert('您输入的费率错误')
                    item.rate = 0.0052
                }
                if(rate < 0.0038 && rate > 0 ){
                    alert("您输入的费率不能小于0.0038")
                    item.rate = 0.0040
                }
            };
            /*通道 二 判断*/
            if(tag == "YILIAN1"){
                if(rate>0.0052){
                    alert('您输入的费率错误')
                    item.rate = 0.0052
                }
                if(rate < 0.0036 && rate > 0 ){
                    alert("您输入的费率不能小于0.0036")
                    item.rate = 0.0040
                }
            };
            /*通道 三 判断*/
            if(tag == "WEIXIN_QRCODE"){
                if(rate>0.0052){
                    alert('您输入的费率错误');
                    item.rate = 0.0052
                }
                if(rate < 0.0027 && rate > 0 ){
                    alert("您输入的费率不能小于0.0027");
                    item.rate = 0.0030
                }
            };
            /*通道 四 判断*/
            if(tag == "WEIXIN_QRCODE1"){
                if(rate>0.0052){
                    alert('您输入的费率错误');
                    item.rate = 0.0052
                }
                if(rate < 0.0025 && rate > 0 ){
                    alert("您输入的费率不能小于0.0025");
                    item.rate = 0.0030
                }
            };
            /*通道 五 判断*/
            if(tag == "ALIPAY_QRCODE"){
                if(rate>0.0052){
                    alert('您输入的费率错误');
                    item.rate = 0.0052
                }
                if(rate < 0.0025 && rate > 0 ){
                    alert("您输入的费率不能小于0.0025");
                    item.rate = 0.0030
                }
            };
            /*通道 六 判断*/
            if(tag == "ALIPAY_QRCODE1"){
                if(rate>0.0052){
                    alert('您输入的费率错误');
                    item.rate = 0.0052
                }
                if(rate < 0.0025 && rate > 0 ){
                    alert("您输入的费率不能小于0.0025");
                    item.rate = 0.0030
                }
            };
            /*通道 七 判断*/
            if(tag == "QQ_QRCODE"){
                if(rate>0.0052){
                    alert('您输入的费率错误');
                    item.rate = 0.0052
                }
                if(rate < 0.0025 && rate > 0 ){
                    alert("您输入的费率不能小于0.0025");
                    item.rate = 0.0030
                }
            };
            /*通道 八 判断*/
            if(tag == "QQ_QRCODE1"){
                if(rate>0.0052){
                    alert('您输入的费率错误');
                    item.rate = 0.0052
                }
                if(rate < 0.0025 && rate > 0 ){
                    alert("您输入的费率不能小于0.0025");
                    item.rate = 0.0030
                }
            };
        };
        $scope.add = function(item){
            /*修改用户刷卡费率*/
            console.log(item);
            var userid = sessionStorage.getItem(key=13);
            var id = item.id;
            var rate = item.rate;
            console.log(userid);
            console.log(id);
            console.log(rate);
            $http({
                method: 'POST',
                params: {
                    user_id:userid,
                    channel_id:id,
                    rate:rate},
                url: window.baseUrl+'user/channel/rate/update/userid'
            }).then(function successCallback(data){
                console.log("修改数据成功...");
                console.log(data.data.result);
                alert("成功设置【"+item.name+item.channelParams+"】通道刷卡费率为"+item.rate)

            }, function errorCallback(data) {
                console.log("修改数据失败...");
                console.log(data)
            })
        }
    });
</script>
</html>




